package com.cgw.dmplt.base.dao.ibatis;

import java.util.List;
import org.apache.log4j.Logger;
import org.springframework.dao.DataAccessException;
import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;
import com.cgw.dmplt.base.domain.BaseRoomtype;
import com.cgw.dmplt.base.dao.BaseRoomtypeDao;

/**
 * BaseRoomtypeDao�ӿ�ʵ����.
 * @author sims autoCoder1.0
 *
 */
public class BaseRoomtypeDaoImpl extends SqlMapClientDaoSupport implements BaseRoomtypeDao
{
    /**
     * logger.
     */
    private static final Logger logger = Logger.getLogger(BaseRoomtypeDaoImpl.class);

    /**
     * �õ�sequence.
     * @return id
     * @throws DataAccessException DataAccessException
     */
    public String getNextId() throws DataAccessException {
    	return (String) getSqlMapClientTemplate().queryForObject("BaseRoomtype_getNextId");
    }
    
    /**
     * insert.
     * @param baseRoomtype baseRoomtype
     * @return id
     * @throws DataAccessException DataAccessException
     */
    public String insertBaseRoomtype(BaseRoomtype baseRoomtype) throws DataAccessException {
		if (logger.isDebugEnabled()) {
    		logger.debug("����insertBaseRoomtype(BaseRoomtype), �������[" + baseRoomtype + "]");
    	}
        
        // �õ�sequence
    	String id = getNextId();
        // todo: set id
        
    	getSqlMapClientTemplate().insert("BaseRoomtype_insertBaseRoomtype", baseRoomtype);
		if (logger.isDebugEnabled()) {
    		logger.debug("�뿪insertBaseRoomtype(BaseRoomtype), ����[" + id + "]");
		}
    	return id;
    }

    /**
     * delete.
     * @param baseRoomtype baseRoomtype
     * @throws DataAccessException DataAccessException
     */
    public void deleteBaseRoomtype(BaseRoomtype baseRoomtype)throws DataAccessException {
		if (logger.isDebugEnabled()) {
    		logger.debug("����deleteBaseRoomtype(BaseRoomtype), �������[" + baseRoomtype + "]");
		}
        getSqlMapClientTemplate().update("BaseRoomtype_deleteBaseRoomtype", baseRoomtype);
		if (logger.isDebugEnabled()) {
    		logger.debug("�뿪deleteBaseRoomtype(BaseRoomtype)");
		}
    }
    
    /**
     * update.
     * @param baseRoomtype baseRoomtype
     * @throws DataAccessException DataAccessException
     */
    public void updateBaseRoomtype(BaseRoomtype baseRoomtype) throws DataAccessException {
		if (logger.isDebugEnabled()) {
    		logger.debug("����updateBaseRoomtype(BaseRoomtype), �������[" + baseRoomtype + "]");
		}
    	getSqlMapClientTemplate().update("BaseRoomtype_updateBaseRoomtype", baseRoomtype);
		if (logger.isDebugEnabled()) {
    		logger.debug("�뿪updateBaseRoomtype(BaseRoomtype)");
		}
    }
    
    /**
     * find.
     * @param id id
     * @return baseRoomtype
     * @throws DataAccessException DataAccessException
     */
    public BaseRoomtype findBaseRoomtype(String pk) throws DataAccessException {
		if (logger.isDebugEnabled()) {
        	logger.debug("����findBaseRoomtype(BaseRoomtype), �������[" + pk + "]");
		}
        BaseRoomtype baseRoomtype = (BaseRoomtype) getSqlMapClientTemplate().queryForObject("BaseRoomtype_findBaseRoomtype", pk);
		if (logger.isDebugEnabled()) {
        	logger.debug("�뿪findBaseRoomtype(BaseRoomtype), ����[" + baseRoomtype + "]");
		}
        return baseRoomtype;
    }
    
    /**
     * list.
     * @param baseRoomtype baseRoomtype
     * @return baseRoomtype list
     * @throws DataAccessException DataAccessException
     */
    public List listBaseRoomtype(BaseRoomtype baseRoomtype) throws DataAccessException {
        List list = getSqlMapClientTemplate().queryForList("BaseRoomtype_list", baseRoomtype);
        return list;
    }  
    
    /**
     * listCount.
     * @param baseRoomtype baseRoomtype
     * @return list count
     * @throws DataAccessException DataAccessException
     */
    public Integer listBaseRoomtypeCount(BaseRoomtype baseRoomtype) throws DataAccessException {
		if (logger.isDebugEnabled()) {
        	logger.debug("����listBaseRoomtypeCount(BaseRoomtype), �������[" + baseRoomtype + "]");
		}
        Integer count = (Integer)getSqlMapClientTemplate().queryForObject("BaseRoomtype_listBaseRoomtypeCount", baseRoomtype);
		if (logger.isDebugEnabled()) {
        	logger.debug("�뿪listBaseRoomtypeCount(BaseRoomtype), ����[" + count + "]");
		}
        return count;
    }  
}
